package top.revery.admin.util;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import top.revery.admin.service.*;

import javax.annotation.PostConstruct;

/**
 * <h1> --- 服务访问映射 --- </h1>
 * Created by  revery.top jun
 * Date  2019-12-05 11:48
 */
@Component
public class FeignServiceMapping {

    /*
    * 省市区
    * */
    public static ChinaCityDataSource chinaCityDataSource;

    /*
    * 分类、栏目
    * */
    public static CategoryDataSource categoryDataSource;


    /*
     * 单页html
     * */
    public static WebPagesDataSource webPagesDataSource;

    /*
     * 热门关键词
     * */
    public static HotKeyWordDataSource hotKeyWordDataSource;

    /*
     * 任务列表
     * */
    public static TaskServiceDataSource taskServiceDataSource;

    /*
    * User Service
    * */
    public static UserInfoDataSource uDataSource;

    @Component
    public static class AutoLoadData{
        @Autowired
        private ChinaCityDataSource chinaCityDataSource;

        @Autowired
        private CategoryDataSource categoryDataSource;

        @Autowired
        private WebPagesDataSource webPagesDataSource;

        @Autowired
        private HotKeyWordDataSource hotKeyWordDataSource;

        @Autowired
        public static TaskServiceDataSource taskServiceDataSource;

        @Autowired
        private UserInfoDataSource uDataSource;

        @PostConstruct
        void init(){
            FeignServiceMapping.chinaCityDataSource = this.chinaCityDataSource;
            FeignServiceMapping.categoryDataSource = this.categoryDataSource;
            FeignServiceMapping.uDataSource = this.uDataSource;
            FeignServiceMapping.webPagesDataSource = this.webPagesDataSource;

            FeignServiceMapping.hotKeyWordDataSource = this.hotKeyWordDataSource;

            FeignServiceMapping.taskServiceDataSource = this.taskServiceDataSource;
        }
    }
}
